package com.example.codegen;

import java.util.ArrayList;
import java.util.Optional;

public class CallExpression implements Expression {
    public Optional<String> className;
    public String methodName;
    // promise to be identifier
    public ArrayList<Variables> args;

    public CallExpression(Optional<String> className, String methodName, ArrayList<Variables> args) {
        this.className = className;
        this.methodName = methodName;
        this.args = args;
    }

    @Override
    public String toJava() {
        return (className.map(s -> s + ".").orElse("")) + methodName + "(" + String.join(", ", args.stream().map(Variables::toJava).toArray(String[]::new)) + ")";
    }

    @Override
    public String toGo() {
        return (className.map(s -> s + ".").orElse("")) + methodName + "(" + String.join(", ", args.stream().map(Variables::toGo).toArray(String[]::new)) + ")";
    }

    @Override
    public String toJs() {
        return (className.map(s -> s + ".").orElse("")) + methodName + "(" + String.join(", ", args.stream().map(Variables::toJs).toArray(String[]::new)) + ")";
    }

    @Override
    public String toCSharp() {
        return (className.map(s -> s + ".").orElse("")) + methodName + "(" + String.join(", ", args.stream().map(Variables::toCSharp).toArray(String[]::new)) + ")";
    }

    @Override
    public String toCJ() {
        return (className.map(s -> s + ".").orElse("")) + methodName + "(" + String.join(", ", args.stream().map(Variables::toCJ).toArray(String[]::new)) + ")";
    }
}
